﻿using UnityEngine;
using System.Collections;
using Memo.Electricity.Engine;
using UnityEngine.SceneManagement;
using System.Runtime.InteropServices;
using Cinemachine;

namespace Memo.Electricity.Game
{
	public class CPlayerTargetGroup : MonoBehaviour
	{
		private CinemachineVirtualCamera a;
		private Transform mPlayer1;
		private Transform mPlayer2;

		private CinemachineTargetGroup mTargetGroup;

		private bool bInit = false;

		private void OnEnable()
		{
			StartCoroutine(Init());
		}

		private IEnumerator Init()
		{
			while (PlayerManager.Inst == null)
				yield return null;
			bInit = true;

			mPlayer1 = PlayerManager.Inst.Player1.transform;
			mPlayer2 = PlayerManager.Inst.Player2.transform;

			mTargetGroup = GetComponent<CinemachineTargetGroup>();
			mTargetGroup.m_Targets = new CinemachineTargetGroup.Target[2];
			mTargetGroup.m_Targets[0].target = mPlayer1;
			mTargetGroup.m_Targets[0].weight = 1;
			mTargetGroup.m_Targets[0].radius = 2;
			mTargetGroup.m_Targets[1].target = mPlayer2;
			mTargetGroup.m_Targets[1].weight = 1;
			mTargetGroup.m_Targets[1].radius = 2;

		}

	}
}